package com.fx.service.impl;

import com.fx.dao.IotBeanDao;
import com.fx.dao.impl.IotBeanDaoImpl;
import com.fx.pojo.IotBean;
import com.fx.service.IotService;

import java.util.List;

/**
 * @author: 梁峰源
 * @date: 2021/10/7 16:36
 * Description:
 */
public class IotServiceImpl implements IotService {

    private IotBeanDao iotBeanDao=new IotBeanDaoImpl();
    @Override
    public void SaveIotData(IotBean iotBean) {
        iotBeanDao.SaveIotBean(iotBean);
    }

    @Override
    public boolean existData(String QueryStartTime) {
        //为null，说明没有该条数据,否者返回true
        return iotBeanDao.queryIotBeanByStartTime(QueryStartTime) != null;
    }

    @Override
    public String Query(String QueryStartTime) {
        if(existData(QueryStartTime)){
            return iotBeanDao.queryIotBeanByStartTime(QueryStartTime).toString();
        }
        return "查询数据为空";
    }

    @Override
    public List<IotBean> QueryAll() {

        return iotBeanDao.queryAll();
    }
}
